<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0,user-scalable=no,minimal-ui">
        <meta name="description" content="">
        <meta name="author" content="">
        <link rel="icon" href="../img/asset-favico.ico">
        <title>修改个人信息</title>
        <link rel="stylesheet" href="../css/page-health-login.css" />
        <link rel="stylesheet" href="../plugins/elementui/index.css" />
        <script src="../plugins/jquery/dist/jquery.min.js"></script>
        <script src="../plugins/healthmobile.js"></script>
        <script src="../plugins/vue/vue.js"></script>
        <script src="../plugins/vue/axios-0.18.0.js"></script>
        <script src="../plugins/elementui/index.js"></script>
    </head>
    <!--获取cookie = 手机号(15562153131) -->
    <script>
        function getCookie(cookieName) {
            var strCookie = document.cookie;
            var arrCookie = strCookie.split("; ");
            for (var i = 0; i < arrCookie.length; i++) {
                var arr = arrCookie[i].split("=");
                if (cookieName == arr[0]) {
                    return arr[1];
                }
            }
            return "";
        }

        var user_id = getCookie("member_login_telephone");
        console.log(user_id);
    </script>
    <body data-spy="scroll" data-target="#myNavbar" data-offset="150">
    <div class="app" id="app">
        <!-- 页面头部 -->
        <div class="top-header">
            <span class="f-left"><i class="icon-back"></i></span>
            <span class="center">传智健康</span>
            <span class="f-right"><i class="icon-more"></i></span>
        </div>
        <div style="margin-left: 20px">修改个人信息</div>

        <!-- 页面内容 -->
        <div class="contentBox">
            <div class="login">
                <form id='login-form'>
                    <div class="input-row">
                        <label>用户名</label>
                        <div class="loginInput">
                            <input v-model="loginInfo.name" style="width:80%" value="" name="name" id='name' type="text" >
                        </div>
                    </div>
                    <div class="input-row">
                        <label>手机号</label>
                        <div class="loginInput">
                            <input v-model="loginInfo.phoneNumber" id='phoneNumber' value="" name="phoneNumber" type="text" placeholder="请输入手机号" disabled>
                        </div>
                    </div>
                    <div class="input-row">
                        <label>性别</label>
                        <div class="loginInput">
                            <input v-model="loginInfo.sex" type="radio" id="sex"  name="sex" value="男" checked> 男
                            <input type="radio" name="sex" value="女"> 女
                        </div>
                    </div>
                    <div class="input-row">
                        <label>身份证号</label>
                        <div class="loginInput">
                            <input v-model="loginInfo.idCard" name="idCard" style="width:80%" id='idCard' value="" type="text" placeholder="身份证" disabled>
                        </div>
                    </div>
                    <div class="input-row">
                        <label>生日</label>
                        <div class="loginInput">
                            <input v-model="loginInfo.birthday" style="width:80%" name="birthday" value="" id='birthday' type="date" placeholder="请输入验证码">
                        </div>
                    </div>
                    <div class="input-row">
                        <label>邮箱</label>
                        <div class="loginInput">
                            <input v-model="loginInfo.email" style="width:80%" name="email" value="" id='email' type="text" placeholder="请输入验证码">
                        </div>
                    </div>
                    <div class="input-row">
                        <label>注册日期</label>
                        <div class="loginInput">
                            <input v-model="loginInfo.regTime" value="" name="regTime" style="width:80%" id='regTime' type="date" disabled>
                        </div>
                    </div>
                    <div class="btn yes-btn"><a @click="commitEdit()" href="#">确认修改</a></div>
                </form>
            </div>
        </div>
    </div>
    </body>
    <script>
        var vue = new Vue({
            el:'#app',
            data:{
                //登录信息
                loginInfo:{
                    name:null,
                    phoneNumber:user_id,
                    regTime:null,
                    idCard:null,
                    email:null,
                    birthday:null,
                    sex:'男'
                },
            },
            methods:{
                //修改
                commitEdit(){
                    //获取用户输入的手机号
                    // var telephone = this.loginInfo.telephone;
                    // if(!checkTelephone(telephone)){
                    //     //输入不正确，弹出提示
                    //     this.$message.error("手机号输入错误，请检查后重新输入！");
                    //     return false;
                    // }
                    axios.post("/member/edit.do",this.loginInfo).then((res) => {
                        if(res.data.flag){
                            //登录成功，跳转到会员首页
                            alert("修改会员信息成功");
                            window.location.href = "member.html";
                        }else{
                            //登录失败，弹出提示
                            this.$message.error(res.data.message);
                        }
                    });
                },
                //修改个人信息页面加载时回显信息
                load(){
                    var param = {
                        phoneNumber:this.loginInfo.phoneNumber
                    };
                    axios.post("/member/commitEdit.do",param).then((res) => {
                        this.loginInfo.regTime = res.data.data.regTime1;
                        this.loginInfo.idCard = res.data.data.idCard;
                        this.loginInfo.email = res.data.data.email;
                        this.loginInfo.birthday = res.data.data.birthday1;
                        this.loginInfo.sex = res.data.data.sex;
                        this.loginInfo.name = res.data.data.name;
                    });
                }
            },
            created(){
                this.load();
            }
        });
    </script>
</html>